(function () {
    fetch('http://chst.vip:1234/api/getindexmenu')
        .then(body => body.json())
        .then(res => {
           
            let result=res.result
            console.log(result)
            let navStr='';
            result.forEach(item => {
               
         
             console.log(item.img)
            
             let regExp = /([^"]+)/g
             let url = item.img.match(regExp);
         console.log(url)

                navStr+=`
                <li date-index='${item.indexmenuId}'>
                <a href='${item.titlehref}'>
                 <img src='../${url[1]}' alt='url[3]'/>
              
                
                <h4>${item.name}</h4>
                </a>
            </li>
        `

            });
            $('.navlis').html($(navStr));
//点击更多  展开第三行
let isShow = true;
$('.navlis > li').eq(7).on('click', function() {
    if (isShow) {
        $(this).parent().stop().animate({ height: '2.55rem' }, 500);
        isShow = false;
    } else {
        $(this).parent().stop().animate({ height: '1.68rem' }, 500);
        isShow = true;
    }
})
});
//获取折扣列表数据  并渲染
fetch('http://chst.vip:1234/api/getmoneyctrl').then(body => body.json()).then(res => {
let result = res.result;
// console.log(result);
let discStr = '';
result.forEach(item => {
    console.log(item)
    let regExp = /(?<=imgurl=)[^'"]*/;
    // console.log(item)
    //处理图片
    let r = item.productImg2.match(regExp);
       
    discStr += `
    <li date-productId="${item.productId}">
            <a href="javascript:;">
                <div class="imgico">
                <img src=${r[0]}  alt="">
                </div>
                <div class="info">
                    <h3>${item.productName}</h3>
                    <span class="price">¥ ${item.productPinkage}</span>
                    <div class="desc">
                        <span class="times">${item.productFrom} | ${item.productTime}</span>
                        <div class="review">
                            <i></i>
                            <span>${item.productComCount}</span>
                        </div>
                    </div>
                </div>
            </a>
        </li>
    `
});
$('.discBody > ul').html($(discStr));
});
$('.discBody').on('click', 'li', function() {

    location.href = '../pages/indexproduct.html?productid=' + $(this).attr('date-productId')
})
})()